﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SubSonic;
using Coolite.Ext.Web;
using CXDB;
using Comparison=SubSonic.Comparison;
public partial class Search_Safty_Default : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            StoredeptBind();
        }
        CXSecurity.ChkBoss(Cookies.getCookies("cuid"));
    }
    protected void Search(object s,AjaxEventArgs e)
    {
        Query q=new Query(VwUserBase.Schema);
        q.SetSelectList("uid,username,deptname");
        if(tfusername.Text!="")
        {
            q.AddWhere("username", Comparison.Like, "%" + tfusername.Text.Trim() + "%");
        }
        if(tfdeptid.SelectedIndex!=-1)
        {
            q.AddWhere("depid", tfdeptid.SelectedItem.Value.ToString());
        }
        StoreUserbase.DataSource = q.ExecuteDataSet();
        StoreUserbase.DataBind();
        
    }
    protected void StoredeptBind()
    {
        Query q = new Query(CxSysDept.Schema);
        q.SetSelectList("id,deptname");
        
        Store_dept.DataSource = q.ExecuteDataSet();
        Store_dept.DataBind();
    }
    protected void StoreDetail_onRefresh(object sender, StoreRefreshDataEventArgs e)
    {
        string id = e.Parameters["uid"];
        Query q = new Query(VwStaffSaftyStep1.Schema);
        q.SetSelectList("id,safty_master_status as adept_master_status,dept_master_status,boss_status,intime,guid");
        q.AddWhere("userid", id);
        q.AddWhere("safty_master_status", 1);
        q.AddWhere("dept_master_status", 1);
        q.AddWhere("boss_status", 1);

        StoreDetail.DataSource = q.ExecuteDataSet();
        StoreDetail.DataBind();
    }
     
    protected void ApplySub(object s,AjaxEventArgs e)
    {
        string id = e.ExtraParams["id"].ToString();
        tfhiddenid.Value = id;
         
        Window1.Show();
    }
    protected void Sub(object s, AjaxEventArgs e)
    {
        ApplyAction.Add(new Guid(tfhiddenid.Value.ToString()),tfreason.Text,"cx_staff_safty");
        Window1.Hide();
    }
    protected void Cancel(object s,AjaxEventArgs e)
    {
        Window1.Hide();
    }

}
